#open(BUFF,"file_final");
open BUFF,"HT_HG-U133A.na29.txt" or die "no file needed\n";
#open BUFF,"/data2/bsi/RandD/gene_id_name_mapping.txt" or die "no file found\n";
#$line = <BUFF>;
while($line = <BUFF>)
{
        chomp($line);
        @array = split(/\t/,$line);
	chomp($array[1]);
	if($array[0] =~ m/\d/ )
	{
		$hash{$array[1]} = $array[0];
	}
=head
	@arr =split(/\|/,$array[2]);
	#print "@arr\n";
	for($i=0;$i<@arr;$i++)
	{
		if($arr[$i]  =~ m/\d/ )
		{	
			chomp($arr[$i]);
			if(exists($hash{$arr[$i]}))
			{
				print "$arr[$i] $array[0] $hash{$arr[$i]}\n";
			}
			$hash{$arr[$i]} = $array[0];
		}
	}
	#print $array[1]."\t".$array[0]."\n";
=cut
}
open(BUFF,"ucsc_genome_hg18_mar_2006");
#open(WRBUFF,">file_final_ucsc");
open(WRBUFF,">file_final_ucsc_new_affy");
$line = <BUFF>;
while($line = <BUFF>)
{
	chomp($line);
	@array = split(/\t/,$line);
	$array[2] =~ s/chr//g;
	chomp($array[0]);
	if(exists($hash{$array[0]}))
	{
		print WRBUFF $hash{$array[0]}."\t".$array[0]."\t".$array[3]."\t".$array[4]."\t".$array[5]."\t".$array[2]."\n";
	}
	else
	{
		print $array[0]."\n";
	}
}

